﻿/*
 作者：张维锋
 */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Orf.dto;
using Orf.Model;

namespace Orf_system.收费业务
{
    public partial class FrmShoufeiJiesuan : Form
    {
        DIC_YGDM empClass = null;
        MZ_CF01 cf01Class = null;
        MZ_SFMX sfmxCalss = null;
        huaJaShoufeiDAO hjsfDAO = null;
        public FrmShoufeiJiesuan()
        {
            InitializeComponent();
            empClass = new DIC_YGDM();
            cf01Class = new MZ_CF01();
            sfmxCalss = new MZ_SFMX();
            hjsfDAO = new huaJaShoufeiDAO();
        }

        private void FrmShoufeiJiesuan_Load(object sender, EventArgs e)
        {
            txtCurrfphm.Text = FrmhuaJiaSf.fphm;
            txtFsum.Text = FrmhuaJiaSf.Fsum;


            empClass.yGDM = FrmLogin.emp_sn;
            cf01Class.fPHM = FrmhuaJiaSf.fphm;
            cf01Class.mZHM = FrmhuaJiaSf.mzhm;
            sfmxCalss.fPHM = FrmhuaJiaSf.fphm;
            sfmxCalss.mZHM = FrmhuaJiaSf.mzhm;
            sfmxCalss.cZGH = FrmLogin.emp_sn;
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtBrJk.Text=="")
            {
                MessageBox.Show("请输入付款金额！");
                return;
            }
            try
            {
                int res = 0;
                res = hjsfDAO.Insert_Sfmx(sfmxCalss);
                if (res > 0)
                {
                    hjsfDAO.Update_Fphm(empClass, 2);
                    hjsfDAO.Insert_Cf01(cf01Class);
                    MessageBox.Show("结算成功，结算方式为" + cbsSkfs.Text + "，金额为" + txtFsum.Text);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("结算失败！");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

        }

        private void txtBrJk_TextChanged(object sender, EventArgs e)
        {
            double fk = Convert.ToDouble(txtBrJk.Text);
            double fsum = Convert.ToDouble(txtFsum.Text);
            double zl = fk - fsum;
            if (txtFsum.Text != "")
            {
                txtZlje.Text = zl.ToString();
            }
        }

        private void txtBrJk_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 13 && e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
            {
                MessageBox.Show("输入数字");
                e.Handled = true;
            }
        }
    }
}
